<?php
// +----------------------------------------------------------------------
// | Author: Fl
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Controller;
use think\Request;
use think\Db;
class Brand extends Common
{
    public function index()
    {       
        $bname = input('bname');
        if($bname){
            $brand=Db::name('brand')->where("bname='$bname'")->order('bid desc')->select();
			ifExist($brand);
        }else{
            $brand=Db::name('brand')->order('bid desc')->select();
        }
		
        $this->assign("brand",$brand);
        $this->assign('a','Brand');
        return $this->fetch();
    }
    public function addlist()
    {
        $this->assign('a','Brand');
        return $this->fetch();
    }
    public function addxinx(){
        $bname = input('bname');
        $data = array(
            'bname' => $bname,
            'btime' => time()
            );
        $brand=Db::name('brand')->insert($data);
        if($brand){
            return 1;
        }
    }
    //编辑信息
    public function update()
    {
        $bid = input('bid');
        $data=Db::name('brand')->where("bid='$bid'")->select();
        $this->assign('a','Brand');
        $this->assign("data",$data);
        return $this->fetch();
    }
    //保存信息
    public function xiugai(){
        $bid = input('bid');
        $bname = input('bname');
        $data = array(
            'bid' => $bid,
            'bname' => $bname,
            'btime' => time()
            );
        $brand=Db::name('brand')->where("bid='$bid'")->update($data);
        if($brand){
            return 1;
        }
        }
    //删除
    public function del(){
        $bid = input('bid');
        $data = array(
            'bid' =>$bid
            );
        $del=Db::name('brand')->where("bid='$bid'")->delete($data);
        if($del){
            return 1;
        }
    }
}